package cyou.breathe.controller;

import cyou.breathe.Results;
import cyou.breathe.dto.req.PurchaseTicketReqDTO;
import cyou.breathe.dto.req.TicketPageQueryReqDTO;
import cyou.breathe.dto.resp.TicketPageQueryRespDTO;
import cyou.breathe.dto.resp.TicketPurchaseRespDTO;
import cyou.breathe.result.Result;
import cyou.breathe.service.TicketService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: breathe
 * @createTime: 2025-06-18
 */
@RestController
@RequiredArgsConstructor
public class TicketController {
    private final TicketService ticketService;

    /**
     * 根据条件查询车票
     */
    @GetMapping("/api/ticket-service/ticket/query")
    public Result<TicketPageQueryRespDTO> pageListTicketQuery(TicketPageQueryReqDTO requestParam) {
        return Results.success(ticketService.pageListTicketQuery(requestParam));
    }

    /**
     * 购买车票
     */
    @PostMapping("/api/ticket-service/ticket/purchase")
    public Result<TicketPurchaseRespDTO> purchaseTickets(@RequestBody PurchaseTicketReqDTO requestParam) {
        return Results.success(ticketService.purchaseTicketsV1(requestParam));
    }

}
